package cn.com.zpark.servlet_request;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @PackageName: cn.com.zpark.servlet_request
 * @ClassName: RequestDemo08
 * @Description:
 * @author: RZS
 * @date: 2021/11/14  16:34
 */
@WebServlet("/rd8.do")
public class RequestDemo08 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 获取转发绑定在request对象中的数据
        Date date = (Date)request.getAttribute("date");

        // 时间格式转换
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String format = simpleDateFormat.format(date);

        System.out.println(format);

    }
}
